import React, {Component} from 'react';
// import memoryUtils from "../../utils/memoryUtil";
import {Redirect, Route, Switch} from 'react-router-dom';
import { Layout} from 'antd';
import Header from '../../components/header/header'
import LeftNav from '../../components/leftNav/leftNav'
import Home from "../../components/home/home";
import Category from "../../components/category/category";
import Product from "../../components/product/product";
import User from "../../components/user/user";
import Bar from "../../components/charts/bar";
import Line from "../../components/charts/line";
import Pie from "../../components/charts/pie";
import Detail from '../../components/product/detail'
// import Login from "../login/login";

const { Footer, Sider, Content } = Layout;

class Admin extends Component {
    render() {
        //如果内存没有存储user ==》 当前没有登录（需要在APP中访问local）
        // const user = memoryUtils.user
        // if(!user||!user.id){
        //     //自动跳转到登录页
        //     return <Redirect to="/login"/>
        // }
        return (
                <Layout style={{width:"100%",height:"100%"}}>
                    <Sider>
                        <LeftNav style={{width:'100%'}}/>
                    </Sider>
                    <Layout>
                        <Header>Header</Header>
                        <Content style={{backgroundColor: "#FFFF",margin:20}}>
                            <Switch>
                                <Route path='/admin/home' component={Home}></Route>
                                <Route path='/admin/category' component={Category}></Route>
                                <Route path='/admin/product' component={Product}></Route>
                                <Route path='/admin/user' component={User}></Route>
                                <Route path='/admin/bar' component={Bar}></Route>
                                <Route path='/admin/line' component={Line}></Route>
                                <Route path='/admin/pie' component={Pie}></Route>
                                <Redirect to='/admin/home'></Redirect>
                            </Switch>
                        </Content>
                        <Footer style={{textAlign:'center',color:'#CCCCCC'}}>推荐使用谷歌</Footer>
                    </Layout>
                </Layout>
        );
    }
}

export default Admin;
